package MercuryTour;

import java.io.File;
import java.io.IOException;

import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.PageFactory;

public class TestLoginPage {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws BiffException 
	 */
	public static void main(String[] args) throws BiffException, IOException {
		
		File file = new File ("c:/test.xls");
		Workbook workbook = Workbook.getWorkbook(file);
		Sheet sheet = workbook.getSheet(2);
		
		
		int sizeOfArray = sheet.getColumns();
		String[] loginInfo = new String[sizeOfArray];
		
		for (int i=0; i< sheet.getRows();i++)
		{
		WebDriver driver = new FirefoxDriver();
		String baseUrl = "http://newtours.demoaut.com/";
		driver.get(baseUrl);
		loginPage loginpage = PageFactory.initElements(driver, loginPage.class);
		
		for (int j=0; j<sheet.getColumns();j++)
		{	
			
			loginInfo[j] = sheet.getCell(j, i).getContents();
	
		}
		loginpage.loginTo(loginInfo);
		driver.close();
		}

	}

}
